<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title><s:property value='%{getText("role_title")}' /></title>
		<link href="/SCMDB/style/main.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="/SCMDB/js/Super.js"></script>
		<script type="text/javascript" src="/SCMDB/js/DatePicker/WdatePicker.js"></script>
		<%@ include file="../commonPage/message.jsp" %>
		
		<script type="text/javascript">
			function validateForm() {
				var beginDate = document.getElementById("beginDate").value;
				var endDate = document.getElementById("endDate").value;
				if(beginDate == "") {
					alert("请输入起始日期");
					return false;
				}
				if(endDate == "") {
					alert("请输入结束日期");
					return false;
				}
				if(beginDate > endDate) {
					alert("起始日期要小于结束日期!");
					return false;
				}
				
				var i = DateDiff(endDate, beginDate);
				if(i > 6) {
					alert("最多只能查询7天, 请重新选择日期!");
					return false;
				}
				return true;
			}
			
			function DateDiff(sDate1, sDate2) {
			   //sDate1和sDate2是2002-12-18格式　　 
			　  var aDate, oDate1, oDate2, iDays;　 
			　  aDate = sDate1.split("-");　 
			　  oDate1 = new Date(aDate[0],aDate[1]-1,aDate[2]);　 
			　  aDate = sDate2.split("-");　 
			　  oDate2 = new Date(aDate[0],aDate[1]-1,aDate[2]);　 
			
			　  iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24);　　 
			　  if((oDate1 - oDate2)<0){　 
			　　　  return -iDays;　 
			　  }　 
			　  return iDays;  
			}
		</script>
	</head>
	<body>
		<h2>
			<s:property value='%{getText("current_position")}' />${parentMenu}>>${currentMenu}
		</h2>
		<div class="main">
		  <s:form action="securityCommentedAction!findAll" method="post" theme="simple">
		  
		  <fieldset class="fieldSearch">
			<legend>查询</legend>
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td align="right" class="p_14">起始日期：</td>
					<td>
						<!-- <input class="sInput" id="d4321" name="beginDate" readonly="readonly" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'d4322\',{d:0});}'})"/> -->
						<s:textfield cssClass="timeInput" id="beginDate" name="beginDate" readonly="true" onclick="WdatePicker()" />
					</td>
					<td align="right" class="p_14">结束日期：</td>
					<td>
						<!--<input class="sInput" id="d4322" name="endDate" readonly="readonly" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'d4321\',{d:6});}'})"/> -->
						<s:textfield cssClass="timeInput" id="endDate" name="endDate" readonly="true" onclick="WdatePicker()" />
					</td>
					<td align="right" class="p_14" colspan="2">
						<s:submit cssClass="bSearch" value="查询" onclick="return validateForm();"></s:submit>
					</td>
				</tr>
			</table>
		</fieldset>
		  
			<table border="0" cellpadding="1" cellspacing="1" class="tableList">
				<thead>
					<tr>
						<th width="10%">姓名</th>
						<s:iterator id="column" value="columnsName"  status="u">
							<td><s:property value="column"/></td>
						</s:iterator>
					</tr>
				</thead>
				<tbody>
				   <s:iterator id="commented" value="list"  status="u">
					  <tr>
						<td><s:property value="empName"/></td>
						<!-- 再用s:iterator迭代值都一样 -->
						<c:forEach items="${commented.columns}" var="columnDate">
							<td>
								<c:if test="${columnDate == 1}">参加</c:if>
								<c:if test="${columnDate == null}"><font color="red">未参加</color></c:if>
							</td>
						</c:forEach>
				      </tr>
				  </s:iterator>
				  
				  <tr>
					<td colspan="8" class="turnPage">&nbsp;<jsp:include flush="true" page="../commonPage/page.jsp"><jsp:param name="entity" value="entity" />
						</jsp:include>
					</td>
				  </tr>
				</tbody>
			</table>			
		  </s:form>
		</div>
	</body>
</html>
